<template>
  <div class="material-print" ref="print">
    <h2 v-if="title==''">物料现存量</h2>
    <h2 v-else>{{title}}{{typeTitle}}</h2>
    <table cellspacing="0" cellpadding="0">
      <thead>
        <tr>
          <th>序号</th>
           <th v-if="type=='total'">仓库</th>
          <th>物料编码</th>
        <th v-if="wmSort.sortAttrMerge==1">物料名称</th>
        <th v-if="wmSort.sortAttrMerge==0">物料名称</th>
        <th v-if="wmSort.sortAttrMerge!==1">{{wmSort.sortAttrAlia}}</th>
          <th>计量单位</th>
          <th v-if="type=='list'">批次日期</th>
          <th v-if="wmSpecail.length>0&&wmSpecail[0].status=='0'&&type=='list'">{{wmSpecail[0].name}}</th>
          <th v-if="wmSpecail.length>1&&wmSpecail[1].status=='0'&&type=='list'">{{wmSpecail[1].name}}</th>
          <th v-if="wmSpecail.length>2&&wmSpecail[2].status=='0'&&type=='list'">{{wmSpecail[2].name}}</th>
          <th v-if="wmSpecail.length>3&&wmSpecail[3].status=='0'&&type=='list'">{{wmSpecail[3].name}}</th>
          <th v-if="wmSpecail.length>4&&wmSpecail[4].status=='0'&&type=='list'">{{wmSpecail[4].name}}</th>
          <th>数量</th>

        </tr>
      </thead>
      <tbody v-if="printData.length>0">
        <tr v-for="(item,index) in printData" :key="index">
          <td>{{item.id}}</td>
            <td v-if="type=='total'">{{item.whName}}</td>
          <td>{{item.invCode}}</td>
        <td v-if="wmSort.sortAttrMerge==1">{{item.invName}}{{item.invAttribute}}</td>
        <td v-if="wmSort.sortAttrMerge==0">{{item.invName}}</td>
        <td v-if="wmSort.sortAttrMerge!==1">{{item.invAttribute}}</td>
          <td>{{item.unitName}}</td>
            <th v-if="type=='list'">{{item.batchDate}}</th>
          <td v-if="wmSpecail.length>0&&wmSpecail[0].status=='0'&&type=='list'">{{item.f1}}</td>
          <td v-if="wmSpecail.length>1&&wmSpecail[1].status=='0'&&type=='list'">{{item.f2}}</td>
          <td v-if="wmSpecail.length>2&&wmSpecail[2].status=='0'&&type=='list'">{{item.f3}}</td>
          <td v-if="wmSpecail.length>3&&wmSpecail[3].status=='0'&&type=='list'">{{item.f4}}</td>
          <td v-if="wmSpecail.length>4&&wmSpecail[4].status=='0'&&type=='list'">{{item.f5}}</td>
          <td>{{item.quantity}}</td>

        </tr>
      </tbody>
    </table>
  </div>

</template>

<script>
  export default {
    data() {
      return {

      }
    },
    mounted() {
      console.log(this.wmSpecail)
    },
    props: {
      // 类型
      type:{
        type: String,
        default () {
          return ""
        }
      },
      //特殊属性
      wmSpecail: {
        type: Array,
        default () {
          return []
        }
      },
      printData: {
        type: Array,
        default () {
          return []
        }
      },
      title: {
        type: String,
        default () {
          return ""
        }
      },
      typeTitle: {
        type: String,
        default () {
          return ""
        }
      },
      //仓库对应分类信息
      wmSort: {
        type: Object,
        default () {
          return {};
        }
      }
    }
  }
</script>

<style lang="scss" scoped="scoped">
  @media print {
    .material-print {
      display: block !important;
    }
  }

  .material-print {
    display: none;
    h2 {
      text-align: center;
      color: #515a6e;
    }

    table {
      width: 100%;
      margin-bottom: 20px;
      border-left: 1px solid #ccc;

      th {
        text-align: center;
        font-size: 14px;
        padding: 5px;
        border-bottom: 1px solid #ccc;
        border-right: 1px solid #ccc;
        border-top: 1px solid #ccc;
      }

      td {
        text-align: center;
        font-size: 13px;
        color: #606266;
        border-bottom: 1px solid #ccc;
        border-right: 1px solid #ccc;
        padding: 5px;
      }
    }
  }
</style>
